package com.airforce.mappers;

import com.airforce.model.award;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface awardMapper {
    @Delete({
        "delete from award",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into award (id, name, ",
        "price, type, rule, ",
        "phase, hightFlag, ",
        "createtime, updatetime)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{price,jdbcType=DECIMAL}, #{type,jdbcType=INTEGER}, #{rule,jdbcType=VARCHAR}, ",
        "#{phase,jdbcType=INTEGER}, #{hightflag,jdbcType=TINYINT}, ",
        "#{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP})"
    })
    int insert(award record);

    @InsertProvider(type=awardSqlProvider.class, method="insertSelective")
    int insertSelective(award record);

    @Select({
        "select",
        "id, name, price, type, rule, phase, hightFlag, createtime, updatetime",
        "from award",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="rule", property="rule", jdbcType=JdbcType.VARCHAR),
        @Result(column="phase", property="phase", jdbcType=JdbcType.INTEGER),
        @Result(column="hightFlag", property="hightflag", jdbcType=JdbcType.TINYINT),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP)
    })
    award selectByPrimaryKey(Integer id);

    @UpdateProvider(type=awardSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(award record);

    @Update({
        "update award",
        "set name = #{name,jdbcType=VARCHAR},",
          "price = #{price,jdbcType=DECIMAL},",
          "type = #{type,jdbcType=INTEGER},",
          "rule = #{rule,jdbcType=VARCHAR},",
          "phase = #{phase,jdbcType=INTEGER},",
          "hightFlag = #{hightflag,jdbcType=TINYINT},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updatetime = #{updatetime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(award record);
    @Select("select * from award where name like #{name}")
    List<award> selectByname(String name );

    @Select("select * from award  ")
    List<award> selectByall();

    @Select("select * from award where phase=#{phase}")
    List<award> selectByPhase(Integer phase);
}